import {GET, POST} from "@/apis";

export interface BookConfig {
    abstract: string
    author: string
    id: string
    image: string
    label: string[]
    link: string
    name: string
    score: number
    type: string
}

// 用户画像元组配置
export type UserProfileConfig = [string, string, number]
// 用户首次登陆时，收集用户喜好信息
export type UserProfile = {
    authors: string[]
    labels: string[]
    types: string[]
}

/* 首次登录时获取图书推荐结果 */
export const getRecommendBooksFirstLogin = (size: number, data: UserProfile) => POST<BookConfig[]>({
    url: `/recommend?size=${size}`,
    data
})

/* 获取图书推荐结果 */
export const getRecommendBooks = (size: number) => GET<BookConfig[]>(`/recommend?size=${size}`)

/* 获取热门书籍 */
export const getBookHotList = (size: number) => GET<BookConfig[]>(`/recommend/hot?size=${size}`)

/* 获取用户历史记录 */
export const getBookHistoryList = (size: number) => GET<BookConfig[]>(`/recommend/history?size=${size}`)

/* 根据图书id获取推荐结果 */
export const getRecommendBookListById = (bookId: string, size: number) => GET<BookConfig[]>(`/recommend/book?bookId=${bookId}&size=${size}`)

/* 获取用户画像 */
export const getUserProfile = () => GET<UserProfileConfig[]>("/recommend/userProfile")

/* 查询用户是否第一次登录 */
export const getUserIsFirstLogin = () => GET<boolean>("/user/firstLogin")
